package com.lemonPiggy.activiti.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.R;
import com.lemonPiggy.activiti.domain.ActKeyPage;
import com.lemonPiggy.activiti.service.IActKeyPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 工作流单关联 Controller
 * 
 * @author ruoyi
 * @date 2021-09-03
 */
@RestController
@RequestMapping("/keyPage")
public class ActKeyPageController extends BaseController
{
    @Autowired
    private IActKeyPageService actKeyPageService;

    /**
     * 查询工作流单关联 列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ActKeyPage actKeyPage)
    {
        startPage();
        List<ActKeyPage> list = actKeyPageService.selectActKeyPageList(actKeyPage);
        return getDataTable(list);
    }

    @PostMapping("/listNoPaging")
    public R<List<ActKeyPage>> listNoPaging(@RequestBody ActKeyPage actKeyPage)
    {
        List<ActKeyPage> list = actKeyPageService.selectActKeyPageList(actKeyPage);
        return R.ok(list);
    }

    /**
     * 导出工作流单关联 列表
     */
    @PreAuthorize(hasPermi = "system:page:export")
    @Log(title = "工作流单关联 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActKeyPage actKeyPage) throws IOException
    {
        List<ActKeyPage> list = actKeyPageService.selectActKeyPageList(actKeyPage);
        ExcelUtil<ActKeyPage> util = new ExcelUtil<ActKeyPage>(ActKeyPage.class);
        util.exportExcel(response, list, "工作流单关联 数据");
    }

    /**
     * 获取工作流单关联 详细信息
     */
    @PreAuthorize(hasPermi = "system:page:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(actKeyPageService.selectActKeyPageById(id));
    }

    /**
     * 新增工作流单关联 
     */
    @PreAuthorize(hasPermi = "system:page:add")
    @Log(title = "工作流单关联 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActKeyPage actKeyPage)
    {
        return toAjax(actKeyPageService.insertActKeyPage(actKeyPage));
    }

    /**
     * 修改工作流单关联 
     */
    @PreAuthorize(hasPermi = "system:page:edit")
    @Log(title = "工作流单关联 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActKeyPage actKeyPage)
    {
        return toAjax(actKeyPageService.updateActKeyPage(actKeyPage));
    }

    /**
     * 删除工作流单关联 
     */
    @PreAuthorize(hasPermi = "system:page:remove")
    @Log(title = "工作流单关联 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(actKeyPageService.deleteActKeyPageByIds(ids));
    }
}
